import os
import json

# 配置文件路径
CONFIG_FILE = 'config.json'


def load_config():
    """加载配置文件"""
    if os.path.exists(CONFIG_FILE):
        with open(CONFIG_FILE, 'r', encoding='utf-8') as f:
            return json.load(f)
    return {
        'deepseek_api_key': 'sk-f1971e4d5516457089433dd100de9ae4',
        'deepseek_api_url': 'https://api.deepseek.com/v1/chat/completions',
        'stock_symbols': ['600519.SS', '000858.SZ', '002594.SZ', '601318.SS', '600036.SS'],  # 贵州茅台、五粮液、比亚迪、中国平安、招商银行
        'lookback_days': 60,
        'database': {
            'host': 'localhost',
            'port': 3306,
            'user': 'root',
            'password': 'password',
            'database': 'stock_analysis'
        }
    }


def save_config(config):
    """保存配置文件"""
    with open(CONFIG_FILE, 'w', encoding='utf-8') as f:
        json.dump(config, f, indent=4, ensure_ascii=False)


# 初始化配置
config = load_config()
